package main

import "fmt"

/*
	接口定义：
		type name interface {
			method1(arg...) return_val
			method2(arg...) return_val
		}
*/
type Usb interface {
	Start()
	Stop()
}

/*
	实现接口：实现接口所有方法即可

*/
type Phone struct {
}

func (phone Phone) Start() {
	fmt.Println("phone working")
}

func (phone Phone) Stop() {
	fmt.Println("phone stop")
}

type Camera struct {
}

func (camera Camera) Start() {
	fmt.Println("Camera working")
}

func (camera Camera) Stop() {
	fmt.Println("Camera stop")
}

type Computer struct {
}

// 多肽
func (computer Computer) working(usb Usb) {
	usb.Start()
	usb.Stop()
}

func main() {
	computer := Computer{}
	phone := Phone{}
	camera := Camera{}

	computer.working(phone)
	computer.working(camera)
	// fmt.Printf("%T\n", phone)
}
